﻿using System;
using System.IdentityModel.Selectors;
using System.IdentityModel.Tokens;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.ServiceModel.Channels;
using System.ServiceModel.Description;
using System.ServiceModel.Dispatcher;
using System.ServiceModel.Security;

namespace SecureService
{
    public class MyCustomValidator : UserNamePasswordValidator
    {
        public override void Validate(string userName, string password)
        {
            if (userName == "test" && password == "123")
            {
                return;
            }
            if (String.IsNullOrEmpty(userName) || String.IsNullOrEmpty(password) || userName.ToUpper() != password.ToUpper())
            {
                throw new SecurityTokenException("Invalid username or password");
            }
        }
    }

}